package com.jule.miaozhuapc.webSocket.server;

import com.jule.miaozhuapc.service.GameService;
import com.jule.miaozhuapc.service.RoomService;
import com.jule.miaozhuapc.webSocket.control.WawaControlWebSocket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RoomCheckUse {


    @Autowired
    private GameService gameService;
    @Autowired
    private RoomService roomService;
    /**
     *  判断房间是否异常
     * @param use 主板发送是否空闲指令 (true = 空闲)
     * @param roomId  房间Id
     */
    public void checkRoom(Boolean use, Integer roomId){
        if (roomId == null) return;

        // 主板空闲但房间被占用释放房间
        if (use && WawaControlWebSocket.PlayData.containsKey(roomId) && WawaControlWebSocket.PlayData.get(roomId) != null){
            WawaControlWebSocket.PlayData.remove(roomId);
        }
    }


    /**
     *  通过查询游戏记录 若10分钟内没有游戏记录，则释放房间
     */
    public void checkRoom(){

        //List<RoomService> roomServices =
    }
}
